/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-21 08:39:23
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-12-22 15:48:28
 * @FilePath: \adminstration\src\Common\Modal\ThrModalList\LabReportTemplates.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { API_LIST } from '../../Api/Api'
import { commonTableList } from '../config'
import { setValueEnumData } from '../../Router/MenuBoxList'

export const LabReportTemplates = async ({ data }) => {
    let dataList = {
        uuid: data.uuid,
        type: '添加试验参数',
        width: 800,
        classification: 'SelectModal',
        isCheckbox: true,
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'code@asc,testCategory.code@asc' },
        get: API_LIST()['getTestType'],
        pos: 'posLabReportTemplateTestTypesBatch',
        assemblyData: e => {
            let list = []
            e.forEach(item => (list = [...list, item.uuid]))
            return list
        },
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'code',
                title: '编号',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
                render: (_, e) => {
                    const { code, testCategory } = e
                    return (
                        <div>
                            {testCategory.code}-{code}
                        </div>
                    )
                },
            },
            {
                dataIndex: 'testCategoryUuid',
                title: '试验类别',
                valueType: 'select',
                valueEnum: {},
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'tableName',
                title: '参数简称',
                valueType: 'input',
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'fullName',
                title: '参数全称',
                valueType: 'input',
                rules: true,
                width: 200,
                hideInSearch: true,
            },
        ],
    }

    dataList.columns.find(v => v.dataIndex === 'testCategoryUuid').valueEnum = await setValueEnumData({
        url: 'getTestCategory',
    })

    return dataList
}
